<template>
	<view class="content">
		<view class="address" v-for="(item, index) in players" :key="index">
			<text class="address-tlt" style="margin-bottom: 24rpx">参赛成绩{{ index + 1 }}</text>
			<view class="user">
				<u-cell-group :border="false">
					<u-cell title="赛事组名" :border="false" :value="item.groupName"> </u-cell>
					<u-cell title="选手姓名" :border="false" :value="item.playerName"> </u-cell>
					<u-cell title="5KM(净)成绩" :border="false" :value="item.result5 || '--'"></u-cell>
					<u-cell title="5KM(枪)成绩" :border="false" :value="item.result5Gun || '--'"></u-cell>
					<u-cell title="10KM(净)成绩" :border="false" :value="item.result10 || '--'"></u-cell>
					<u-cell title="10KM(枪)成绩" :border="false" :value="item.result10Gun || '--'"></u-cell>
					<u-cell title="15KM(净)成绩" :border="false" :value="item.result15 || '--'"></u-cell>
					<u-cell title="15KM(枪)成绩" :border="false" :value="item.result15Gun || '--'"></u-cell>
					<u-cell title="20KM(净)成绩" :border="false" :value="item.result20 || '--'"></u-cell>
					<u-cell title="20KM(枪)成绩" :border="false" :value="item.result20Gun || '--'"></u-cell>
					<u-cell title="21.0975KM(净)成绩" :border="false" :value="item.result21 || '--'"></u-cell>
					<u-cell
						title="21.0975KM(枪)成绩"
						:border="false"
						:value="item.result21Gun || '--'"
					></u-cell>
					<u-cell title="25KM(净)成绩" :border="false" :value="item.result25 || '--'"></u-cell>
					<u-cell title="25KM(枪)成绩" :border="false" :value="item.result25Gun || '--'"></u-cell>
					<u-cell title="30KM(净)成绩" :border="false" :value="item.result30 || '--'"></u-cell>
					<u-cell title="30KM(枪)成绩" :border="false" :value="item.result30Gun || '--'"></u-cell>
					<u-cell title="35KM(净)成绩" :border="false" :value="item.result35 || '--'"></u-cell>
					<u-cell title="35KM(枪)成绩" :border="false" :value="item.result35Gun || '--'"></u-cell>
					<u-cell title="40KM(净)成绩" :border="false" :value="item.result40 || '--'"></u-cell>
					<u-cell title="40KM(枪)成绩" :border="false" :value="item.result40Gun || '--'"></u-cell>
					<u-cell title="42.195KM(净)成绩" :border="false" :value="item.result42 || '--'"></u-cell>
					<u-cell
						title="42.195KM(枪)成绩"
						:border="false"
						:value="item.result42Gun || '--'"
					></u-cell>
					<u-cell title="平均配速" :border="false" :value="item.avgSpeedPei || '--'"></u-cell>
					<u-cell title="平均时速" :border="false" :value="item.avgSpeedShi || '--'"></u-cell>
					<u-cell title="性别净名次" :border="false" :value="item.sexRank || '--'"></u-cell>
					<u-cell title="性别枪名次" :border="false" :value="item.sexRankGun || '--'"></u-cell>
					<u-cell title="年龄段净名次" :border="false" :value="item.ageRank || '--'"></u-cell>
					<u-cell title="年龄段枪名次" :border="false" :value="item.ageRankGun || '--'"></u-cell>
					<u-cell title="全部净名次" :border="false" :value="item.allRank || '--'"></u-cell>
					<u-cell title="全部枪名次" :border="false" :value="item.allRankGun || '--'"></u-cell>
				</u-cell-group>
			</view>
			<u-line dashed margin="10rpx 0 14rpx" color="#aaa"></u-line>
			<view class="flex-r">
				<u-button
					text="查看证书"
					color="#e50012"
					shape="circle"
					size="small"
					customStyle="width:150rpx;height:52rpx;font-size:32rpx"
					:throttleTime="1500"
					:hoverStopPropagation="true"
					@click.native.stop="onDownloadFile(item)"
				></u-button>
			</view>
		</view>

		<view class="footer">
			<button class="footer-btn" @click="onSubmit">返回</button>
		</view>
	</view>
</template>

<script>
const app = getApp()
export default {
	data() {
		return {
			id: '',
			info: {},
			players: [],
			isLock: false
		}
	},
	async onLoad(options) {
		this.id = options.id
		this.getDetailInfo()
	},
	methods: {
		getDetailInfo() {
			/* prettier-ignore */
			this.$https( true, 'get', {
				url:'/member/result/score/'+this.id,
				data: {}
			},(res) => {
				this.info = res.data
				this.players = res.data.players || []
			})
			/* prettier-ignore */
		},

		async onDownloadFile(item) {
			/* prettier-ignore */
			this.$https( true, 'get', {
					url: `/member/result/download/${this.id}/${item.playerId}`
				},
				(res) => {
					if(!res.data){
						uni.$u.toast('暂无证书，请稍后查看！')
						return
					}
					console.log(res.data)
					uni.previewImage({
						urls: [res.data]
					});
				})
			/* prettier-ignore */
		}
	}
}
</script>

<style lang="scss" scoped>
.content {
	width: 100%;
	padding: 20rpx 0 130rpx;
	position: relative;
}
.address {
	padding: 24rpx 28rpx;
	width: calc(702rpx - 56rpx);
	overflow-x: hidden;
	background-color: #fff;
	border-radius: 16rpx;
	margin: 0 auto 24rpx;
	&-tlt {
		font-size: 28rpx;
		color: #898989;
		border-bottom: 1px solid #e9e9e9;
		display: block;
		padding-bottom: 18rpx;
		&:before {
			display: inline-block;
			content: '';
			width: 8rpx;
			height: 30rpx;
			float: left;
			margin: 4rpx 10rpx 0;
			background-color: #0071c5;
		}
	}
}
.tips {
	background-color: #d4f0ff;
	font-size: 26rpx;
	color: #0071c5;
	padding: 16rpx 20rpx;
	line-height: 36rpx;
	margin: 12rpx 6rpx 10rpx;
}
.footer {
	width: calc(100% - 48rpx);
	padding: 0 24rpx;
	height: 120rpx;
	background-color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	position: fixed;
	bottom: 0;
	z-index: 9;
	border-top: 1px solid #e5e5e5;
	&-btn {
		width: 684rpx;
		height: 80rpx;
		background-color: #eee;
		border-radius: 16rpx;
		font-size: 30rpx;
		color: #666;
		margin: 0;
	}
}
::v-deep {
	.u-cell .u-cell__body {
		padding: 6rpx 12rpx;
		.u-cell__title-text {
			font-size: 28rpx;
			color: #898989;
			min-width: 200rpx;
		}
		.u-cell__value {
			font-size: 28rpx;
			font-weight: 500;
			color: #231815;
		}
	}
	.u-button {
		margin: 0;
	}
}
</style>
